﻿CREATE VIEW EmployeesUsersView  as 
SELECT e.Id,
u.UserId, 
FirstName,
Middlename,
LastName,
Mobile,
DepartmentId,
DesignationId,
e.Email,
e.IsConsultant,
CAST(ISNULL(e.ID,'') as varchar)+' '+ISNULL(e.FirstName,'')+ +' '+ISNULL(e.Middlename,'')+' '+ISNULL(e.LastName,'')+' ' +ISNULL(e.Mobile,'')+' '+ISNULL(e.Email,'')+' '+ ISNULL(u.UserId,'') as SearchString,
(select COUNT(1) from UserProfiles where UserId=u.UserId)as IsProfileMapped
FROM Employees e
LEFT OUTER JOIN Users u
ON e.ID=u.EmployeeID
go

